// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import iView from 'iview/dist/iview.min'
import 'iview/dist/styles/iview.css'
import axios from 'axios'

Vue.config.productionTip = false
Vue.use(iView)
Vue.prototype.$axios = axios

// Add a request interceptor
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  iView.LoadingBar.start()
  return config
}, function (error) {
  // Do something with request error
  return Promise.reject(error)
})

// Add a response interceptor
axios.interceptors.response.use(function (response) {
  // Do something with response data
  iView.LoadingBar.finish()
  return response
}, function (error) {
  // Do something with response error
  iView.LoadingBar.error()
  return Promise.reject(error)
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
